package com.qf.lanzhou.blog.api.controller;

import com.qf.lanzhou.blog.api.service.ChangeReportCommentService;
import com.qf.lanzhou.blog.api.service.impl.ChangeReportCommentServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author 是柠檬甜
 * @ClassName CommentReportChangeServlet
 * @description 举报评论修改状态功能
 * @date 2020/12/21 17:51
 * @modifier 是柠檬甜
 * @date 2020-12-21 17:51
 * @Version V1.0
 */
@WebServlet("/reportCommentStatusChange.do")
public class CommentReportChangeServlet extends BaseServletPost {
    private ChangeReportCommentService commentService=new ChangeReportCommentServiceImpl();
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String commentId = req.getParameter("commentId");
        long commentIdLong = Long.parseLong(commentId);
        try{
            String message = commentService.changeStatus(commentIdLong);
            successResultWrite(message,resp);
        }catch (RuntimeException e){
            String errorMessage = e.getMessage();
            failedResultWrite(errorMessage,resp);
        }

    }
}
